/* Copyleft
 * Created by Charles in UESTC
 * May the odds be ever in your favor!
 */
#ifndef MAZE_H
#define MAZE_H

#include <stack>
#include <vector>
using namespace std;

class Maze
{
    //利用int的四个二进位表示迷宫block的可通状态,SEALED表示各个方向都不通
    const static int UP = 1;
    const static int RIGHT = 2;
    const static int DOWN = 4;
    const static int LEFT = 8;
    const static int SEALED = 15;
    
    //边，用于kruskal构建迷宫
    struct edge
    {
        //边的两个顶点
        int first;
        int second;
    };

    private:
        //存储迷宫的数组
        vector<int> maze;
        //标记是否走过的数组
        bool *visited;
        int outblock;
        int mazeSize;
        stack<int> path;
        //用于生成迷宫
        vector<edge> Edges;
        //存储结点数组,用于生成迷宫
        int *v;
        int root(int i);
        //walk 用于递归求解，内存占用太高，已换用循环求解
        //bool walk(int current);
    public:
        Maze(int size = 20);
        Maze(vector<int> mazeVec);
        Maze(int *mazeArray, int size);
        void setMaze(int *mazeArray, int size);
        void setMaze(vector<int> mazeVec);
        vector<int> getMaze();
        void newMaze(int size);
        vector<int> getPath();
        bool solve();
        int getSize();
};
#endif
